import { request } from '../server/request'

// 用户信息接口
export interface UserInfo {
  name: string
  avatar: string
  tel: string
  email: string
}

// 登录参数接口
export interface LoginParams {
  username: string
  password: string
}

// 登录响应接口
export interface LoginResponse {
  token: string
}

// 刷新 token 响应接口
export interface RefreshTokenResponse {
  isRefreshToken: boolean
  token: string
}

/**
 * 用户登录
 */
export const loginApi = (data: LoginParams) => {
  return request.post<LoginResponse>('/login', data)
}

/**
 * 获取用户信息
 */
export const getUserInfoApi = () => {
  return request.get<UserInfo>('/getUserInfo')
}

/**
 * 刷新 token
 */
export const refreshTokenApi = () => {
  return request.post<RefreshTokenResponse>('/refreshToken')
}

